<template>

  <div  style="margin-left:1000px;margin-top: 10px;">
    <i class="el-icon-money" style="font-weight:bolder;font-size: 30px">总收入：{{nums}}</i>
  </div>


  <div id="myChart" style="width:100%;height:60%;margin-top:200px;">
  </div>

<!--{{nums}}-->
<!--  {{size}}-->
</template>

<script>
import echarts from "echarts"
import http, {service} from "@/http/request";
import {getUserListApi} from "@/api/user";
export default {
  name: "DeskTop",
  data(){
      return{
        nums:'',
        size:'',
        name: [],
        num: []
      }
  },
  created() {
    this.sumAll()
    // this.shuX()
    this.getAllEcharts()
  },
  methods:{

    async getAllEcharts() {
      const {data: res1} = await service.get("sumVo");
      console.log(res1);
      this.num = res1.num;
      this.name = res1.name;
      console.log(this.num,"111")
      this.setChart();
    },
    setChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = echarts.init(document.getElementById('myChart'))
      // console.log(this.chart)
      // 指定图表的配置项和数据
      var option = {
        title: {
          text: "医院收入"
        },
        tooltip: {},
        legend: {
          data: ["住院部收入", '门诊部收入']
        },
        xAxis: {
          data: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],
        },
        yAxis: {},
        series: [
          {
            name: "住院部收入",
            type: "bar",
            data: this.num,
          },
          {
            name: '门诊部收入',
            type: 'bar',
            data: this.name
          },
        ],
      }
      this.chart.setOption(option);
    },
    sumAll(){
      service.get("http://localhost:8088/sumMoney")
          .then((v) => {
            this.nums = v.data;
            console.log("3333333333",this.nums)
          })
    },




    dome(){
      //this.$root => app
      let myChart = echarts.init(
          document.getElementById("myChart")
      );
      //
      // 绘制图表
      myChart.setOption({
        title: {
          text: 'ECharts 入门示例'
        },
        // tooltip: {},
        legend: {
          data: ['销量','测试']
        },
        xAxis: {
          data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
        },
        yAxis: {},
        series: [
          {
            name: '销量',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20]
          },
          {
            name: '测试',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20]
          }
        ],
      });
    },
  },

  mounted() {
    this.dome()
  }

}
</script>

<style scoped>

</style>